package com.gosophia.conferenceManagement.notification.ws.test.integration;

import javax.xml.ws.WebServiceException;

import junit.framework.Assert;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;

import com.gosophia.commons.exception.BusinessException;
import com.gosophia.conferenceManagement.notification.dto.NotificationJobDataDTO;
import com.gosophia.conferenceManagement.notification.ws.NotificationWebService;
import com.gosophia.userManagement.dto.UserInfoDTO;

/**
 * 测试通知
 * @author gaoweiguang
 *
 */
@ContextConfiguration(locations = { "classpath*:moduleContext.xml",
"classpath:applicationContext-test.xml" })
@TransactionConfiguration(defaultRollback = true)
@Transactional(rollbackFor = WebServiceException.class)
public class ITNotificationWebServiceImpl extends
AbstractTransactionalJUnit4SpringContextTests{
   @Autowired
   private NotificationWebService notificationWebService;
   
    /**
     * 测试添加会议异常
     * @throws BusinessException
     */
	@Test(expected=IllegalArgumentException.class)
	public void testaddNotificationJobData1() throws BusinessException{
		notificationWebService.addNotificationJobData(null);
	}
	
    /**
     * 测试添加会议异常
     * @throws BusinessException
     */
	@Test(expected=IllegalArgumentException.class)
	public void testaddNotificationJobData2() throws BusinessException{
		NotificationJobDataDTO notificationJobDataDTO = new NotificationJobDataDTO();
		notificationJobDataDTO.setJobDataId(1L);
		notificationWebService.addNotificationJobData(notificationJobDataDTO);
	}
	
    /**
     * 测试添加会议正常
     * @throws BusinessException
     */
	@Test
	public void testaddNotificationJobData3() throws BusinessException{
		NotificationJobDataDTO notificationJobDataDTO = new NotificationJobDataDTO();
		notificationJobDataDTO.setJobId(1L);
		UserInfoDTO userInfo = new UserInfoDTO();
		userInfo.setUserInfoId(3L);
		notificationJobDataDTO.setNextApproval(userInfo);
		notificationJobDataDTO.setNotificationType("0");
		notificationWebService.addNotificationJobData(notificationJobDataDTO);
	}
 
    /**
     * 测试查询通知会议DTO异常
     * @throws BusinessException
     */
	@Test(expected=IllegalArgumentException.class)
	public void testfindNotificationJobDataByJobId1() throws BusinessException{
		notificationWebService.findNotificationJobDataByJobId(null);
	}
	
    /**
     * 测试查询通知会议DTO正常
     * @throws BusinessException
     */
	@Test
	public void testfindNotificationJobDataByJobId2() throws BusinessException{
		NotificationJobDataDTO notificationJobDataDTO = new NotificationJobDataDTO();
		
		notificationJobDataDTO = notificationWebService.findNotificationJobDataByJobId(1L);
		Assert.assertEquals("0", notificationJobDataDTO.getNotificationType());
		Assert.assertEquals("处理意见", notificationJobDataDTO.getOpinion());
	}
	
	
}
